<?php include('header.php');?>
<style>
.cke_chrome{
	width:480px !important;
}
</style>
<head>
<script type="text/javascript" src="ckeditor/ckeditor.js"></script>
</head>
<div id="contents">
		<div id="header"></div>
    <div class="container-fluid">
		<div class="row-fluid container_bg">
				<div id="sidemenu"></div>
			<div class="span9 pos_r">
				<div class="container_title">
				<center>
				<form id="newslettrform" method="POST" action="newsletterprocess.php">
						<div class=""><h1>News Letter</h1></div>
						
					<div>
						<div class="boxMiddle" id="listContent">
							<span id="successmsg" style="color:red" class="adminNewsLetter"></span>
							<div class="tab-content">
								<div id="inline1" class="tab-pane active" style="width:600px; min-height:100px;">
									<div class="PopUp">
										<form enctype="multipart/form-data" id="messageform" name="messageform" method="POST">
												<span id="msg_nr">
													<div class="pad_t8">
														<input type="text" id="subject" style="border:1px solid #ccc;height:34px;width:480px;padding-left:10px;" name="subject" value="" placeholder="Subject"/><span id="errorSubject" name="errorSubject" style="color:red"></span>
														<div class="clear hig20">
														</div>
													</div>
												</span>
												</br/>
														<textarea  style="border:1px solid #ccc;height:25px;width:480px" id="message" name="message" contenteditable="true" class="editablecontent"></textarea><span id="errorMessage" name="errorMessage" style="color:red"></span>
											
							
												<a href="javascript:void(0);" class="news_btn" onclick="valid_messageform2();">Save</a>
													
										</form>
									</div>
								</div>
							</div>
						 <div style="clear:both"></div>
						</div> 
					</div>
				</form>
			</center>
				</div>
				  
			</div>
		</div>
    </div>
</div>
<?php include('footer.php')?>
<script src="js/jquery.js" type="text/javascript"></script>
<script>
	$(document).ready(function() {
			CKEDITOR.replace( 'message', {
			});
	});
	function valid_messageform2(){
		var flag=true;
		var subject=$('#subject').val();
		if(subject=='')
		{
			$('#errorSubject').html('Subject Should not be empty');
			flag=false;
		}else{
			$('#errorSubject').html("");
		}
		$('textarea[name="message"]').val(CKEDITOR.instances.message.getData());
		var desc=$('#message').val().replace("<p>","");
		desc=desc.replace("</p>","");
		if(desc=="")
		{
			$('#errorMessage').html("news letter msg should not be empty");
			flag=false;
		}else{
			$('#errorMessage').html("");
		}
		if(flag==true){	
			$('#newslettrform').submit();
		}
	}	
	function add_tag(tag){
	  var desc=$('#messageform').find('.nicEdit-main').html();
	  $('#message').val(nicEditors.findEditor('message').getContent());
	  var cdesc=desc+"{"+tag+"}";
	  $('#message').val(nicEditors.findEditor('message').setContent(cdesc));  
   }
</script>

